<?php
    include "./config.php";
    include "./lang/" . $lang;

    function get_user_data($database)
    {
        $db = new SQLite3("./db/" . $database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
        if (!$db || !file_exists("./db/" . $database)) {
            die("XYNTA");
        }
        else {
            $query = "SELECT username, password, comments FROM users_data";
            $result = $db -> query($query);
            return $result;
        }
        $db -> close();
    }

    function write_user_data($username, $password, $comments, $database)
    {
        $db = new SQLite3("./db/" . $database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
        if (!$db || !file_exists("./db/" . $database)) {
            die("XYNTA");
        }
        else {
            $query = "INSERT INTO users_data (username, password, comments) VALUES (" . "'" . $username . "', " . "'" . $password . "', " . "'" . $comments . "')";
            $db -> query($query);
        }
        $db -> close();
    }
?>
